﻿<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CSS3 SVG点击复选框勾选动画特效</title>

<style>
@import url("https://fonts.googleapis.com/css?family=Exo");
html {
  font-size: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background-color: #00acc1;
  font-family: 'Exo', sans-serif;
}

input[type="checkbox"] {
  display: none;
}
input[type="checkbox"] + .label {
  position: relative;
  padding-left: 1.7em;
  color: #ffffff;
  font-size: 3.125rem;
  cursor: pointer;
}
input[type="checkbox"] + .label::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 1em;
  height: 1em;
  border: 3px solid #ffffff;
  border-radius: 0.1em;
}
input[type="checkbox"] + .label::after {
  content: '';
  position: absolute;
  top: 0.1em;
  left: 0.1em;
  width: 0.92em;
  height: 0.92em;
  transform: scale(0);
  background-color: #ffffff;
  border-radius: 0.02em;
  transition: all 0.2s linear;
  opacity: 0;
}
input[type="checkbox"] + .label svg {
  position: absolute;
  top: 0.2em;
  left: 0.12em;
  z-index: 1;
}
input[type="checkbox"] + .label #check-icon {
  stroke: #00acc1;
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
}
input[type="checkbox"]:checked + .label::after {
  transform: scale(1);
  opacity: 1;
}
input[type="checkbox"]:checked + .label #check-icon {
  animation-name: check-animation;
  animation-duration: 0.2s;
  animation-delay: 0.4s;
  animation-fill-mode: forwards;
  animation-timing-function: cubic-bezier(1, 0.12, 0.96, 0.62);
}

@keyframes check-animation {
  0% {
    stroke-dashoffset: 36;
  }
  100% {
    stroke-dashoffset: 0;
  }
}
</style>

</head>
<body>

<input type="checkbox" id="check-me">

<label for="check-me" class="label">
	Check Me!
	<svg viewBox="-9 -9 43 35.191" width="43" height="35">
    	<path id="check-icon" d=" M 0 9 Q 8 17 8 17 Q 8 17 25 0" fill="none" stroke-width="6" stroke="rgb(0,0,0)" stroke-linecap="round" />
    </svg>
</label>

</body>
</html>